import { ApiCall } from "tsrpc";
import { masterServer } from "../../MasterServerMain";
import { ReqLeaveSubWorld, ResLeaveSubWorld } from "../../shared/protocols/masterServer/PtlLeaveSubWorld";
import { MasterServerConn } from "../MasterServer";
import { DBUser } from "../DBUser";

export async function ApiLeaveSubWorld(call: ApiCall<ReqLeaveSubWorld, ResLeaveSubWorld>) {
    let req = call.req;
    let info = (call.conn as MasterServerConn).userInfo;

    DBUser.updateUserDataByToken(info.token!, { subWorldId: '' });
    call.succ({});
}